import { request } from '../../request';

// get user info by id exclude password
export function fetchGetUserInfoById(id: CommonType.IdType) {
  return request<Api.System.User.UserInfoRecord>({
    url: '/rbac/user_info/getById',
    method: 'get',
    params: {
      id
    }
  });
}

// save model
export function fetchUserInfoSave(model: Api.System.User.UserInfoFormModel) {
  return request({
    url: '/rbac/user_info/save',
    method: 'post',
    data: model
  });
}

// get user info and department by page
export function fetchGetUserInfoByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.User.UserInfoQueryRecord>({
    url: '/rbac/user_info/listByPage',
    method: 'post',
    data: params
  });
}

// delete by id
export function fetchDeleteUserInfoById(id: CommonType.IdType) {
  return request({
    url: '/rbac/user_info/deleteById',
    method: 'post',
    params: {
      id
    }
  });
}

// delete user batch by ids
export function fetchDeleteUserInfoBatchByIds(ids: CommonType.IdType[]) {
  return request({
    url: '/rbac/user_info/deleteBatchByIds',
    method: 'post',
    data: ids
  });
}

// unlock locked user
export function fetchUnlockUserById(id: CommonType.IdType) {
  return request({
    url: '/rbac/user_info/unlockById',
    method: 'post',
    params: {
      id
    }
  });
}

// logout by user id
export function fetchLogoutUserById(id: CommonType.IdType) {
  return request({
    url: '/rbac/auth/logoutByUserId',
    method: 'post',
    params: {
      userId: id
    }
  });
}

// get list by page
export function fetchGetUserPostByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.User.UserPostQueryRecord>({
    url: '/rbac/userpost/listByPage',
    method: 'post',
    data: params
  });
}

export function fetchGetUserPostList() {
  return request<Api.System.User.UserPostRecord[]>({
    url: '/rbac/userpost/listAll',
    method: 'get'
  });
}

// delete by id
export function fetchDeleteUserPostById(id: CommonType.IdType) {
  return request({
    url: '/rbac/userpost/deleteById',
    method: 'post',
    params: {
      id
    }
  });
}

// save model
export function fetchUserPostSave(model: Api.System.User.UserPostFormModel) {
  return request({
    url: '/rbac/userpost/save',
    method: 'post',
    data: model
  });
}

// get user department list
export function fetchGetUserDeptList(userId: CommonType.IdType) {
  return request<Api.System.User.UserDeptRecord[]>({
    url: '/rbac/userdept/getUserDeptList',
    method: 'post',
    params: {
      userId
    }
  });
}

// delete user dept 移出部门
export function fetchDeleteUserDept(params: Api.System.User.UserDeptModel) {
  return request({
    url: '/rbac/userdept/deleteByParams',
    method: 'post',
    data: params
  });
}

// user add another department
export function fetchSaveUserDeptBatch(params: Api.System.User.UserDeptOperateModel) {
  return request({
    url: '/rbac/userdept/saveBatch',
    method: 'post',
    data: params
  });
}

// user reset password
export function fetchUserResetPasswordBatch(params: Api.System.User.UserResetPasswordModel) {
  return request({
    url: '/rbac/user_info/resetPassword',
    method: 'post',
    data: params
  });
}
